/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import dsa.*;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Jack
 */
public class JackKoppenaalTest {
    
    public JackKoppenaalTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }
    
   
        

    /**
     * Test of size method, of class LinkedList.
     */
    @Test
    public void testSize() {
        System.out.println("size");
        LinkedList instance = new LinkedList();
        instance.addFirst("item1");
        instance.addFirst("item2");
        instance.addFirst("item3");
        int expResult = 3;
        int result = instance.size();
        assertEquals(expResult, result);

    }


    /**
     * Test of get method, of class LinkedList.
     */
    @Test
    public void testGet() {
        System.out.println("get");
        int i = 0;
        LinkedList instance = new LinkedList();
        Object expResult = "tada";
        instance.addFirst(expResult);
        Object result = instance.get(i);
        assertEquals(expResult, result);
    }
    
    /**
     * Test of get method, of class LinkedList, when the LinkedList is empty.
     */
    @Test
    public void testGetEmpty(){
        System.out.println("getEmpty");
        int i = 0;
        LinkedList instance = new LinkedList();
        Object expResult = null;
        Object result = instance.get(i);
        assertEquals(expResult, result);
    }

    /**
     * Test of remove method, of class LinkedList.
     */
    @Test
    public void testRemove() {
        System.out.println("remove");
        int i = 1;
        Object o = "item2";
        LinkedList instance = new LinkedList();
        instance.addLast("item1");
        instance.addLast(o);
        instance.addLast("item3");
        instance.remove(i);
        assertEquals(instance.size(), 2);

    }


    /**
     * Test of indexOf method, of class LinkedList.
     */
    @Test
    public void testIndexOf() {
        System.out.println("indexOf");
        LinkedList instance = new LinkedList();
        Object o = "item2";
        instance.addLast("item1");
        instance.addLast(o);
        instance.addLast("item3");
        int expResult = 1;
        int result = instance.indexOf(o);
        assertEquals(expResult, result);
    }

    /**
     * Test of lastIndexOf method, of class LinkedList.
     */
//    @Test
//    public void testLastIndexOf() {
//        System.out.println("lastIndexOf");
//        Object o = "item2";
//        LinkedList instance = new LinkedList();
//        instance.addLast("item1");
//        instance.addLast(o);
//        instance.addLast("item3");
//        instance.addLast(o);
//        int expResult = 3;
//        int result = instance.lastIndexOf(o);
//        assertEquals(expResult, result);
//    }

    /**
     * Test of contains method, of class LinkedList, for when contains is true.
     */
    @Test
    public void testContainsTrue() {
        System.out.println("containsTrue");
        Object o = "item2";
        LinkedList instance = new LinkedList();
        instance.addFirst("item1");
        instance.addFirst(o);
        instance.addFirst("item3");
        boolean expResult = true;
        boolean result = instance.contains(o);
        assertEquals(expResult, result);

    }
    
        /**
     * Test of contains method, of class LinkedList, for when contains is false.
     */
    @Test
    public void testContainsFalse() {
        System.out.println("containsFalse");
        Object o = "item2";
        LinkedList instance = new LinkedList();
        instance.addFirst("item1");
        instance.addFirst("item1");
        instance.addFirst("item3");
        boolean expResult = false;
        boolean result = instance.contains(o);
        assertEquals(expResult, result);

    }


    /**
     * Test of set method, of class LinkedList.
     */
    @Test
    public void testSet() {
        System.out.println("set");
        int i = 0;
        Object o = "item2";
        LinkedList instance = new LinkedList();
        instance.addLast("item1");
        instance.set(i, o);
        assertEquals(instance.get(i), o);
    }

    /**
     * Test of toArray method, of class LinkedList.
     */
    @Test
    public void testToArray() {
        System.out.println("toArray");
        LinkedList instance = new LinkedList();
        Object o1 = "item1";
        Object o2 = "item2";
        instance.addLast(o1);
        instance.addLast(o2);
        Object[] expResult = {o1, o2};
        Object[] result = instance.toArray();
        assertEquals(expResult, result);
    }

    @Test
    public void testEquals(){
        System.out.println("equals");
        LinkedList instance = new LinkedList();
        instance.addFirst("item1");
        instance.addFirst("item1");
        instance.addFirst("item3");
        LinkedList test = new LinkedList();
        test.addFirst("item1");
        test.addFirst("item1");
        test.addFirst("item3");
        assertEquals(instance.toArray(), test.toArray());
    }
   }

